import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class ButtonPage extends StatefulWidget {
  @override
  _ButtonPageState createState() => _ButtonPageState();
}

class _ButtonPageState extends State<ButtonPage>
    with SingleTickerProviderStateMixin {
  AnimationController _controller;

  @override
  void initState() {
    _controller = AnimationController(vsync: this);
    super.initState();
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return
        /*
      Scaffold(
        appBar: AppBar(
          title: Text("按钮演示"),
        ),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.add),
          onPressed: () {

          },
          backgroundColor: Colors.red,
      ),
      body: Column(
        children: <Widget>[
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              RaisedButton(
                child: Text("普通按钮"),
                onPressed: () {

                },
              ),
              SizedBox(height: 5,width: 5,),
              RaisedButton(
                child: Text("颜色按钮"),
                color: Colors.pink,
                textColor: Colors.white,
                onPressed: () {

                },
              ),
              SizedBox(height: 5,width: 5,),

              RaisedButton(
                child: Text("阴影按钮"),
                color: Colors.green,
                textColor: Colors.white,
                elevation: 15,
                onPressed: () {

                },
              ),

               RaisedButton.icon(
                 icon: Icon(Icons.search),
                 label: Text("图标按钮"),
                 color: Colors.pinkAccent,
                 onPressed: () {

                 },
               )
            ],
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              RaisedButton(
                child: Text("自适应按钮"),
                color: Colors.deepOrange,
                elevation: 30,
                shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(20)
                ),
                onPressed: () {

                },
              )
            ],
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              RaisedButton(
                child: Text("圆形按钮"),
                shape: CircleBorder(
                  side: BorderSide(
                    color: Colors.red,
                  ),

                ),
                onPressed: () {

                },
              )
            ],
          ),
          Row(
            children: <Widget>[
              FlatButton(
                child: Text("flat按钮"),
                color: Colors.deepOrange,
                onPressed: (){

                },
              )
            ],
          ),
          Row(
            children: <Widget>[

            ],
          ),
        ],
      ),
    );*/
        Scaffold(
            appBar: AppBar(
              title: Text('按钮演示页面'),
              actions: <Widget>[
                IconButton(
                  icon: Icon(Icons.settings),
                  onPressed: () {},
                )
              ],
            ),
            body: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Row(
                  children: <Widget>[
                    RaisedButton(
                      child: Text('普通'),
                      onPressed: () {
                        print('普通按钮');
                      },
                    ),
                    SizedBox(width: 5),
                    RaisedButton.icon(
                      icon: Icon(Icons.search),
                      label: Text('图标'),
                      onPressed: null,
                    ),
                    SizedBox(width: 10),
                    RaisedButton(
                      child: Text('有颜色'),
                      color: Colors.blue,
                      textColor: Colors.white,
                      onPressed: () {
                        print('有颜色按钮');
                      },
                    ),
                    SizedBox(width: 10),
                    RaisedButton(
                        child: Text('有阴影'),
                        color: Colors.blue,
                        textColor: Colors.white,
                        elevation: 10,
                        onPressed: () {
                          print('有阴影按钮');
                        }),
                  ],
                ),
                SizedBox(height: 10),
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Container(
                      height: 50,
                      width: 350,
                      child: RaisedButton(
                        child: Text('宽度高度'),
                        color: Colors.blue,
                        textColor: Colors.white,
                        elevation: 20,
                        onPressed: () {},
                      ),
                    )
                  ],
                ),
                SizedBox(height: 10),
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Expanded(
                        child: Container(
                      height: 60,
                      margin: EdgeInsets.all(10),
                      child: RaisedButton(
                        child: Text('自适应按钮'),
                        color: Colors.blue,
                        textColor: Colors.white,
                        elevation: 20,
                        onPressed: () {
                          print('自适应按钮');
                        },
                      ),
                    ))
                  ],
                ),
                SizedBox(height: 10),
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    RaisedButton(
                      child: Text('圆角按钮'),
                      color: Colors.blue,
                      textColor: Colors.white,
                      elevation: 20,
                      shape: RoundedRectangleBorder(
                          borderRadius: BorderRadius.circular(10)),
                      onPressed: () {},
                    ),
                    RaisedButton(
                      child: Text('圆形按钮'),
                      color: Colors.blue,
                      textColor: Colors.white,
                      elevation: 20,
                      splashColor: Colors.grey,
                      shape:
                          CircleBorder(side: BorderSide(color: Colors.white)),
                      onPressed: () {
                        print('圆形按钮');
                      },
                    )
                  ],
                ),
                FlatButton(
                  //扁平化按钮：
                  child: Text('扁平化的按钮'),
                  color: Colors.blue,
                  textColor: Colors.yellow,
                  onPressed: () {},
                ),
                OutlineButton(
                  child: Text('线框按钮'),
                  onPressed: () {
                    print('OutlineButton');
                  },
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Expanded(
                      child: Container(
                        margin: EdgeInsets.all(20),
                        height: 50,
                        child: OutlineButton(
                          child: Text('注册'),
                          onPressed: () {},
                        ),
                      ),
                    )
                  ],
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    ButtonBar(
                      //按钮组
                      children: <Widget>[
                        RaisedButton(
                          child: Text('登录'),
                          color: Colors.blue,
                          textColor: Colors.white,
                          onPressed: () {},
                        ),
                        RaisedButton(
                          child: Text('注册'),
                          color: Colors.blue,
                          textColor: Colors.white,
                          onPressed: () {},
                        ),
                      ],
                    )
                  ],
                ),
                MyButton(
                  text: "自定义按钮",
                  height: 60.0,
                  width: 100.0,
                  pressed: () {
                    print("自定义按钮");
                  },
                )
              ],
            ));
  }
}

class MyButton extends StatelessWidget {
  final text;
  final pressed;
  final double width;
  final double height;

  const MyButton(
      {this.text = '', this.pressed = null, this.width = 80, this.height = 30});

  @override
  Widget build(BuildContext context) {
    return Container(
      height: this.height,
      width: this.width,
      child: RaisedButton(
        child: Text(this.text),
        onPressed: this.pressed,
        color: Colors.green,
      ),
    );
  }
}
